# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         demo1741
# Description:
# Author:       yzl
# Date:         2019-02-08
#-------------------------------------------------------------------------------

from atexit import register
import random
from threading import Thread,Lock,currentThread
from time import sleep,ctime

lock = Lock()
def func():
    lock.acquire()

    for i in range(5):
        print('Thread name','=',currentThread().name,'i','=',i)
        sleep(random.randint(1,5))

    lock.release()

def main():
    for i in range(3):
        Thread(target=func).start()

@register
def exit():
    print('线程执行完毕:',ctime())

if __name__ == '__main__':
    main()

